﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data;
using System.Data.SqlClient;

public partial class TheatreStaff_SalesReports : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
        //srcgrdSession.SelectParameters["username"].DefaultValue = Page.User.Identity.Name;
        //srcgrdSchedule.SelectParameters["username"].DefaultValue = Page.User.Identity.Name;
        //grdSpecialTickets.Sort("MovieTitle", SortDirection.Ascending);
        
        string connectionString;
        connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

        SqlConnection con = new SqlConnection(connectionString);
        SqlConnection con1 = new SqlConnection(connectionString);
        SqlCommand cmd = new SqlCommand("SELECT TheatreId from TheatreStaff WHERE TheatreStaffUsername=@username", con);
        cmd.Parameters.AddWithValue("@username", Page.User.Identity.Name);
       
        using (con)
        {
            con.Open();
            object TheatreID = cmd.ExecuteScalar();
            if (TheatreID != null)
            {
                lblId.Text = TheatreID.ToString();
            }
        }
        //SqlCommand cmd1 = new SqlCommand("SELECT Movie.MovieTitle,Movie.MovieId FROM Movie WHERE Movie.TheatreId=@TheatreId", con1);
        //cmd1.Parameters.AddWithValue("@TheatreId", lblId.Text);

        //using (con1)
        //{
        //    con1.Open();
        //    SqlDataReader Reader = cmd1.ExecuteReader();

        //    if (Reader.HasRows)
        //    { 
        //        while (Reader.Read())
        //        {
                    
        //        }
        //    }

        srcMovie.FilterExpression = "title LIKE '%{0}%' OR sessiondate= '{1}'";
        //srcMovie.FilterExpression = "title LIKE '%{0}%'";

        
        //}
        SqlConnection con3 = new SqlConnection(connectionString);
        SqlCommand cmd2 = new SqlCommand("SELECT TheatreId from TheatreStaff WHERE TheatreStaffUsername=@username", con3);

        cmd2.Parameters.AddWithValue("@username", Page.User.Identity.Name);

        using (con3)
        {
            con3.Open();
            object TheatreID = cmd2.ExecuteScalar();
            if (TheatreID != null)
            {
                lblId.Text = TheatreID.ToString();
            }
        }
        SqlConnection con4 = new SqlConnection(connectionString);
        SqlCommand cmd3 = new SqlCommand("SELECT Theatrename from Theatre WHERE Theatreid=@theatreid", con4);

        cmd3.Parameters.AddWithValue("@theatreid", lblId.Text);


        using (con4)
        {
            con4.Open();
            object Theatrename = cmd3.ExecuteScalar();

            if (Theatrename != null)
            {
                Label4.Text = Theatrename.ToString();

            }
        }

    }
   
}
